home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / nfss-addons / npsfont.sty < prev    next >
Text File  |  1993-04-01  |  7KB  |  194 lines

  1. %% BEGIN npsfont.sty
  2. %%
  3. \def\fileversion{v1.0}
  4. \def\filedate{91/11/20}
  5. %%
  6. %% Style option npsfont.sty, for use with LaTeX 2.09
  7. %%   and the New Font Selection Scheme.
  8. %%
  9. %% COPYRIGHT 1992, by Timothy Van Zandt, tvz@Princeton.EDU
  10. %%
  11. %% Copying of part or all of this file is allowed under the following
  12. %% conditions only:
  13. %% (1) You may freely distribute unchanged copies of the file. Please
  14. %%     include the documentation when you do so.
  15. %% (2) You may modify a renamed copy of the file, but only for personal
  16. %%     use or use within an organization.
  17. %% (3) You may copy fragments from the file, for personal use or for use
  18. %%     in a macro package for distribution, as long as credit is given
  19. %%     where credit is due.
  20. %%
  21. %% You are NOT ALLOWED to take money for the distribution or use of
  22. %% this file or modified versions or fragments thereof, except for
  23. %% a nominal charge for copying etc.
  24. %%
  25. % DESCRIPTION:
  26. %
  27. % Defining new PostScript fonts with the New Font Selection Scheme is easy,
  28. % but these macros make it easier. They save on keystrokes, and most
  29. % importantly, they make it easy to change the file names used for fonts
  30. % because you only have to type the file name once instead of 12 times (for
  31. % the 12 standard LaTeX sizes). An optional argument lets you scale the fonts.
  32. %
  33. % These macros are substitutes for the NFSS's \new@fontshape command. For
  34. % information on the purpose of this command, and on how to select fonts that
  35. % are defined with it, see the documentation of the NFSS. If you don't have
  36. % the NFSS, it is available from
  37. %   rusmv1.rus.uni-stuttgart.de
  38. % in
  39. %   soft/tex/latex-style-supported/New-Font-Selection
  40. % and from
  41. %   ymir.claremont.edu
  42. % in
  43. %   [.anonymous.tex.inputs.latex-mainz]
  44. % The NFSS is undoubtably the best way to use PostScript fonts (or any non-
  45. % standard fonts) with LaTeX, and is well worth upgrading to.
  46. %
  47. % USAGE:
  48. %
  49. %   \newpsfont[<scaling>]{<family>}{<series>}{<shape>}{<filename>}
  50. %
  51. %   \newpsfamily[<scaling>]{<family>}{
  52. %     {<series 1>}{<shape 1>}{<filename 1>},
  53. %     {<series 2>}{<shape 2>}{<filename 2>},
  54. %                 . . .
  55. %     {<series n>}{<shape n>}{<filename n>}}
  56. %
  57. % The scaling argument is optional. Like the \new@fontshape command, these
  58. % commands can only be used in the preamble.
  59. %
  60. % EXAMPLE:
  61. %
  62. % Suppose the Helvetica-Oblique virtual font on your system has the name
  63. % phvro.vf. The following defines the <helvetica> family, <m>edium series, and
  64. % <it>alic shape to be the Helvetica-Oblique font, at the standard LaTeX
  65. % font sizes, scaled by .82:
  66. %
  67. %   \newpsfont[.82]{helvetica}{m}{it}{phvro}
  68. %
  69. % This is equivalent to:
  70. %
  71. %   \new@fontshape{helvetica}{m}{it}{%
  72. %     <5>phvro at 4.1pt%
  73. %     <6>phvro at 4.92pt%
  74. %     <7>phvro at 5.74pt%
  75. %     <8>phvro at 6.56pt%
  76. %     <9>phvro at 7.38pt%
  77. %     <10>phvro at 8.2pt%
  78. %     <11>phvro at 8.979pt%
  79. %     <12>phvro at 9.84pt%
  80. %     <14>phvro at 11.808pt%
  81. %     <17>phvro at 14.1696pt%
  82. %     <20>phvro at 17.0068pt%
  83. %     <25>phvro at 20.4016pt}{}
  84. %
  85. % The following command sets up the standard Helvetica family:
  86. %
  87. %   \newpsfamily[.82]{helvetica}{%
  88. %     {m}{n}{phvr},                          %Helvetica
  89. %     {m}{it}{phvro},                        %Helvetica-Oblique
  90. %     {m}{sl}{phvro},                        %Helvetica-Oblique
  91. %     {bx}{n}{phvb},                         %Helvetica-Bold
  92. %     {bx}{it}{phvbo},                       %Helvetica-BoldOblique
  93. %     {bx}{sl}{phvbo}}                       %Helvetica-BoldOblique
  94. %
  95. % (Don't forget the commas.) It is equivalent to:
  96. %
  97. %   \newpsfont[.82]{helvetica}{m}{n}{phvr}     %Helvetica
  98. %   \newpsfont[.82]{helvetica}{m}{it}{phvro}   %Helvetica-Oblique
  99. %   \newpsfont[.82]{helvetica}{m}{sl}{phvro}   %Helvetica-Oblique
  100. %   \newpsfont[.82]{helvetica}{bx}{n}{phvb}    %Helvetica-Bold
  101. %   \newpsfont[.82]{helvetica}{bx}{it}{phvbo}  %Helvetica-BoldOblique
  102. %   \newpsfont[.82]{helvetica}{bx}{sl}{phvbo}  %Helvetica-BoldOblique
  103. %   \extra@def{helvetica}{}{}
  104. %
  105. % WHY SCALE FONTS?:
  106. %
  107. % Disclaimer: The suggestions that follow come from someone who doesn't know
  108. % anything about fonts.
  109. %
  110. % Mixing fonts that are not designed to be used together is not for purists,
  111. % but many of us do it anyway. Scaling the fonts can at least correct for
  112. % differences in the x-heights. This is important if you use Computer
  113. % Modern fonts for in-line math and some other fonts for text.
  114. %
  115. % To find out the x-height of the 10pt size of a font, load this style and
  116. % use the command
  117. %
  118. %   \showxheight{<filename>}
  119. %
  120. % E.g., \showxheight{phvr} and \showxheight{cmr10} displays
  121. %
  122. %   x-height of cmr10 at 10pt is 4.30554pt
  123. %   x-height of phvr at 10pt is 5.24998pt
  124. %
  125. % on the terminal. Scaling the Helvetica fonts by 4.30554/5.24990 = .82
  126. % gets the x-heights of these fonts in line. It is best to set the x-heights
  127. % the same for the medium weight, normal shaped fonts, and then scale the
  128. % rest of the fonts in the same family by the same amount.
  129. %
  130. % David Jones has a psfonts.sty that sets up the standard PostScript fonts,
  131. % all scaled so that the x-heights match that of the Computer Modern medium
  132. % roman font. It is available via anonymous ftp from theory.lcs.mit.edu in
  133. % /pub/dmjones.
  134. %
  135. % IMPLEMENTATION:
  136. %
  137. % \scale@stdsizes has at its argument a scaling factor. It uses \font@scale
  138. % to define \scaled@sizes to be the macro whose argument is the name of a
  139. % font, and which expands to the definitions of the standard \LaTeX{} sizes
  140. % for New Font Selection Schemes \new@fontshape command.
  141. %
  142. \message{\space\space\fileversion\space\space\filedate
  143.   \space\space<tvz>}
  144. \@ifundefined{new@psfontshape}{}{\endinput}
  145. \def\font@scale#1#2#3{\dimen@=#2\dimen@=#3\dimen@
  146.   \edef\scaled@sizes##1{\scaled@sizes{##1}<#1>##1 at\number\dimen@ sp}}
  147. \def\scale@stdsizes#1{%
  148.   \edef\scaled@sizes##1{}%
  149.   \font@scale{5}{5pt}{#1}%
  150.   \font@scale{6}{6pt}{#1}%
  151.   \font@scale{7}{7pt}{#1}%
  152.   \font@scale{8}{8pt}{#1}%
  153.   \font@scale{9}{9pt}{#1}%
  154.   \font@scale{10}{10pt}{#1}%
  155.   \font@scale{11}{10.95pt}{#1}%
  156.   \font@scale{12}{12pt}{#1}%
  157.   \font@scale{14}{14.4pt}{#1}%
  158.   \font@scale{17}{17.28pt}{#1}%
  159.   \font@scale{20}{20.74pt}{#1}%
  160.   \font@scale{25}{24.88pt}{#1}}
  161. \def\new@psfontshape#1#2#3#4{%
  162.   \new@fontshape{#1}{#2}{#3}{\scaled@sizes{#4}}{}}
  163. \def\new@psfont[#1]#2#3#4#5{%
  164.   \scale@stdsizes{#1}%
  165.   \new@psfontshape{#2}{#3}{#4}{#5}}
  166. \def\newpsfont{%
  167.   \@ifnextchar [{\new@psfont}{\new@psfont[1]}}
  168. \def\newpsfamily{%
  169.   \@ifnextchar [{\new@psfamily}{\new@psfamily[1]}}
  170. \def\new@psfamily[#1]#2#3{%
  171.   \scale@stdsizes{#1}%
  172.   \@for\@tempa:=#3\do{%
  173.     \edef\@tempb{\noexpand\new@psfontshape{#2}\@tempa}
  174.     \@tempb}%
  175.   \extra@def{#2}{}{}}
  176. \def\showxheight#1{%
  177.   \font\@tempfont=#1 at 10pt%
  178.   \typeout{^^J x-height of #1 at 10pt is \the\fontdimen5\@tempfont}}
  179. % The commands are added to \@preamblecmds to save memory.
  180. \begingroup
  181.   \def\do{\noexpand\do\noexpand}
  182.   \xdef\@preamblecmds{\@preamblecmds
  183.     \do\font@scale
  184.     \do\scale@stdsizes
  185.     \do\scaled@sizes
  186.     \do\new@psfontshape
  187.     \do\new@psfont
  188.     \do\newpsfont
  189.     \do\newpsfamily
  190.     \do\new@psfamily}
  191. \endgroup
  192. \endinput
  193. %% END npsfont.sty
  194.